﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace VirtualPress.Infrastructure.Entities.Repository
{
    [Table("C_ImportantPan")]
    public class C_ImportantPan : IEntity<C_ImportantPan>
    {
        [Key]
        [DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        public int meetingId { get; set; }

        [Column(TypeName="nvarchar")]
        [StringLength(128)]
        public string Title { get; set; }

        public DateTime PanDate { get; set; }

        public DateTime CreateDate { get; set; }

        public override C_ImportantPan Find(string key)
        {
            int id = Int32.Parse(key);
            return Find(c => c.Id == id);
        }

        public override C_ImportantPan Find(System.Linq.Expressions.Expression<Func<C_ImportantPan, bool>> where)
        {
            using (Context ctx = new Context())
            {
                return ctx.ImportantPan.FirstOrDefault(where);
            }
        }

        public override bool Any(System.Linq.Expressions.Expression<Func<C_ImportantPan, bool>> where)
        {
            using (Context ctx = new Context())
            {
                return ctx.ImportantPan.Any(where);
            }
        }
    }
}
